package com.ge.boot_02_annotation.config;

import com.ge.boot_02_annotation.bean.Cat;
import com.ge.boot_02_annotation.bean.Dog;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: SpringBoot
 * @BelongsPackage: com.ge.boot_02_annotation.config
 * @Author: gejingyu
 * @Date: 2024/1/23
 * @Description: 测试 条件注解
 */

@Configuration
public class AppConditionConfig {

    /**
     * ConditionalOnClass注解表示类存在时执行以下操作
     * 属性写入全类名
     * 导入druid相关依赖就有这个类
     */
    @ConditionalOnClass(name = "com.alibaba.druid.DruidRuntimeException")
    @Bean
    public Cat cat01(){
        return new Cat();
    }

    @ConditionalOnMissingClass(value = "com.alibaba.druid.DruidRuntimeException")
    @Bean
    public Dog dog01(){
        return new Dog();
    }
}
